package com.nike.amoeba.adapter

import android.view.View
import android.widget.Filter
import android.widget.Filterable
import android.widget.ListView
import androidx.core.content.ContextCompat
import androidx.core.view.size
import com.blankj.utilcode.util.StringUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.flyco.roundview.RoundTextView
import com.nike.amoeba.R
import com.nike.amoeba.bean.DataBean
import com.nike.amoeba.bean.db.AssetBean
import com.nike.amoeba.bean.db.MainDrawerBean
import com.nike.amoeba.ext.INVENTORY_FAIL
import com.nike.amoeba.ext.INVENTORY_NOT
import com.nike.amoeba.ext.INVENTORY_STOCK
import com.nike.amoeba.ext.setAdapterAnimation
import com.nike.amoeba.util.SettingUtil
import com.skydoves.progressview.ProgressView
import org.json.JSONObject
import java.text.NumberFormat

/**
 * @Author nike
 * @Date 2023/7/7 17:05
 * @Description
 */
class DownloadAdapter(data: ArrayList<MainDrawerBean>) :
    BaseQuickAdapter<MainDrawerBean, BaseViewHolder>(R.layout.i_download, data) {

    init {
        setAdapterAnimation(SettingUtil.getListMode())
    }

    override fun convert(viewHolder: BaseViewHolder, bean: MainDrawerBean) {
        data[viewHolder.layoutPosition].run {
            viewHolder.setText(R.id.tv_title, Name)
            val progressView = viewHolder.getView<ProgressView>(R.id.preview_view)
            progressView.progressFromPrevious = true
            val numberFormat = NumberFormat.getInstance()
            numberFormat.setMaximumFractionDigits(2)
            var result = numberFormat.format(progress / Total.toFloat() * 100).toFloat()
            progressView.progress = result
            progressView.labelText = "${progress.toInt()}" + "/" + "$Total" + " " + "${result}%"
        }
    }

}